<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script src="/webjars/stomp-websocket/stomp.min.js"></script>
</head>
<body>
    <div id="greet"></div>
    <script>

        let socket = new WebSocket('wss://localhost/websocket')
        let stompClient = Stomp.over(socket)
        stompClient.connect({}, function () {
            stompClient.subscribe('/broadcast/greet', function (frame) {
                showGreeting(`收到信息: ${frame.body}`)
            })
        })

        function showGreeting(clientMessage) {
            document.getElementById("greet").innerText += `${clientMessage}\n`
        }

    </script>
</body>
</html>
